package com.delivery.www.service.ServiceImpl;

import com.delivery.www.dao.CommentDao;
import com.delivery.www.po.Comment;
import com.delivery.www.service.CommentService;
import com.delivery.www.dao.DaoImpl.CommentDaoImpl;

import java.util.List;

/**
 * @author 12970
 */
public class CommentServiceImpl implements CommentService {
    private final CommentDao commentDao = new CommentDaoImpl();

    @Override
    public boolean doComment(int storeId, int userId, String content, int belongsCommentId, int userIdentity) {
        if (storeId <= 0 || userId <= 0 || content == null || belongsCommentId < 0 || userIdentity < 0) {
            return false;
        } else {
            return commentDao.doComment(storeId, userId, content, belongsCommentId, userIdentity) > 0;
        }
    }

    @Override
    public List<Comment> getComment(int storeId) {
        if (storeId <= 0) {
            return null;
        } else {
            return commentDao.getComment(storeId);
        }
    }

    @Override
    public boolean deleteComment(int commentId, int storeId) {
        if (commentId <= 0 || storeId <= 0) {
            return false;
        } else {
            return commentDao.deleteComment(commentId, storeId) > 0;
        }
    }
}
